<template>
<!-- 	<u-tabbar v-model="current" :list="list" :mid-button="false" height="106rpx" icon-size="46rpx"
		inactive-color="#C3C3C3" active-color="#6C8BFC" :border-top="false" @change="changeIndex"></u-tabbar> -->
	<view class="">
			
		
	<u-tabbar
	    :value="currindex"
	    @change="change"
	    :fixed="true"
		:placeholder="true"
	    :safeAreaInsetBottom="true"
		:activeColor="'#25D59F'"
	>
		<u-tabbar-item v-for="(item,index) in list" :key="index" :text="item.text">
		<image
					class="u-page__item__slot-icon"
					slot="active-icon"
					:src="item.selectedIconPath"
				></image>
				<image
					class="u-page__item__slot-icon"
					slot="inactive-icon"
					:src="item.iconPath"
				></image>
		</u-tabbar-item>
		<!-- <u-tabbar-item
		    text="首页"
		    icon="home"
		>
		</u-tabbar-item>
		<u-tabbar-item
		    text="关于我们"
		    icon="photo"
		></u-tabbar-item>
		<u-tabbar-item
		    text="直播"
		    icon="play-right"
		></u-tabbar-item>
		<u-tabbar-item
		    text="我的"
		    icon="account"
		></u-tabbar-item> -->
	</u-tabbar>
	</view>
</template>

<script>
  // import {actionTrackSave} from "../../common/track.js";
	export default {
		props: {
		  currindex: {
		    type: Number,
		    default: 0
		  },
		
		},
		data() {
			return {
					value1: 0,
					value2: 1,
					value3: 'play-right',
					value4: 0,
					value5: 0,
					value6: 0,
					value7: 3,
				list: [{
						iconPath: "/static/tabbar/home.png",
						selectedIconPath: "/static/tabbar/home-active.png",
						text: '首页',
						pagePath: "/pages/index/index",
						customIcon: false,
					},
					{
						iconPath: "/static/tabbar/fuli.png",
						selectedIconPath: "/static/tabbar/fuli-active.png",
						text: '福利',
						pagePath: "/pages/shop/index",
						customIcon: false,
					},
					{
					  iconPath: "/static/tabbar/tizhong.png",
					  selectedIconPath: "/static/tabbar/tizhong-active.png",
					  text: '体重服务',
					  pagePath: "/pages/service/index",
					  midButton: true,
					  customIcon: false,
					},
					{
						iconPath: "/static/tabbar/faxian.png",
						selectedIconPath: "/static/tabbar/faxian-active.png",
						text: '发现',
						pagePath: "/pages/finds/index?id=1",
						customIcon: false,
					},
					{
						iconPath: "/static/tabbar/wode.png",
						selectedIconPath: "/static/tabbar/wode-active.png",
						text: '我的',
						pagePath: "/pages/member/member",
						customIcon: false,
					},
				],
				current: 0
			}
		},
		onLoad() {
			// uni.hideTabBar();
			// var origin=location.origin;
			// var web=origin+"/mobile";
			// this.src="https://szlh.ai.qh-1.cn/mobile?href="+encodeURI(web) + "&frame="+sessionStorage.frame;
		},
		methods: {
			goPage(e){
				
					this.globals.linkJump({
					  url:e,
					  callback: () => {
					    uni.setStorageSync('pagelist',e)
					  }
					});
					// uni.navigateTo({
					// 	url: e
					// })
				
			
			},
			change(name) {
				console.log(name)
				// if (name === 1) return 
				if(name === 4){
					if(!this.vuex_token){
						uni.$u.toast('请您先登录')
						uni.$u.sleep(500).then(() => {
							uni.navigateTo({
							  url: '/pages/login/login'
							})
						})
					}else{
						// this.goPage(this.list[name].pagePath)
						uni.switchTab({
							url:this.list[name].pagePath
						})
					}
					
				}
				else {
					this.value5 = name
					// this.goPage(this.list[name].pagePath)
					uni.switchTab({
						url:this.list[name].pagePath
					})
				}
				// uni.navigateTo({
				// 	url:this.list[name].pagePath
				// })
			},
			change1(e) {
				this.value1 = e
				console.log('change1', e);
			},
			goToPage(e) {
				console.log('click1', e);
				// uni.navigateTo({
				// 	url:
				// })
			},
			beforeSwitch(index) {
				// 只能切换偶数项
				console.log(index)
			},
			changeIndex(index) {
        console.log(index);

    //     let obj = this.list[index]

    //     // if(obj &&obj.trackPath){
    //     //   actionTrackSave(obj.trackPath,"click")
    //     // }

				// var origin=location.origin;
				// var web=origin+"/mobile";
				// this.src="https://szlh.ai.qh-1.cn/mobile?href="+encodeURI(web) + "&frame="+sessionStorage.frame;
				// if(index == 1) {
				// 	window.location.href = this.src;
				// }
			}
		}
	}
</script>
<style lang="scss" scoped>
	.u-page__item__slot-icon{
		width: 36rpx;
		height: 36rpx;
	}
</style>